var http = require("http");
var url = require("url");
var router = require("./router");

function start1() {
    function onRequest(request, response) {
        var pathname = url.parse(request.url).pathname;
        console.log("Request for " + pathname + " received.");
        response.writeHead(200, {
            "Content-Type": "text/plain"
        });
        response.write("Hello World");
        response.end();
    }

    http.createServer(onRequest).listen(8888);
    console.log("Server has started.");
}
// start1()

console.log('__filename', __filename );// 它将输出文件所在位置的绝对路径
console.log('__dirname', __dirname ); // 表示当前执行脚本所在的目录
// 输出当前目录
console.log('当前目录: ' + process.cwd());

// 输出当前版本
console.log('当前版本: ' + process.version);
// 返回 Node 已经运行的秒数。
console.log(process.uptime())

// 输出内存使用情况
console.log(process.memoryUsage());
function start2() {
    function onRequest(request, response) {
        var pathname = url.parse(request.url).pathname;
        console.log("Request for " + pathname + " received.");

        router.route(pathname);

        response.writeHead(200, {
            "Content-Type": "text/plain"
        });
        response.write("Hello World");
        response.end();
    }

    http.createServer(onRequest).listen(8888);
    console.log("Server has started.");
}
// start2()

var util = require('util'); 

console.log(util.isDate(2019-01-10))